<?php
/**
 * Created by PhpStorm.
 * User: lijie
 * Date: 2018/10/26
 * Time: 15:14
 */
namespace app\reserve\validate;

use think\Validate;

class UserAddressValidate extends Validate {


    protected $rule = [
        'id'                => ['require'],
        'u_id'              => ['require'],
        'linkman'           => ['require'],
        'phone'             => ['require','regex' => '0?(13|14|15|17|18|19)[0-9]{9}',],
        'lon'               => ['require'],
        'lat'               => ['require'],
        'address'           => ['require'],

    ];

    protected $message = [
        'id'                => 'id参数错误',
        'linkman'           => '联系人不能为空',
        'phone'             => '手机号参数错误',
        'lon'               => '经度参数错误',
        'lat'               => '纬度参数错误',
        'address'           => '地址不能为空',
        'type'              => '类型不能为空',
        'u_id'              => 'u_id不能为空',
    ];

    protected $scene = [
        // 添加
        'addUserAddress'        => ['u_id','linkman','phone','lon','lat','address'],
        // 删除
        'delUserAddress'        => ['id'],
        // 编辑用户地址
        'editUserAddress'       => ['id','phone'=>['regex'=>'0?(13|14|15|17|18|19)[0-9]{9}']],
        // 查询用户地址
        'userAddressList'       => ['id'=>'number'],
        // 查找用户地址
        'findDefault'           => ['u_id']
    ];
}